package com.cbs.android.function.imagepick;

import android.content.Intent;
import android.net.Uri;

import com.cbs.android.component.application.activity.handler.CBSSimpleActivityResultHandler;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by broche on 07/11/2016.
 */

public abstract class ImagePickHandler extends CBSSimpleActivityResultHandler {
    public abstract void onPickSuccess(int requestCode, Intent intent, List<Uri> result);

    @Override
    public final void onSuccess(int requestCode, Intent intent) {
        List<Uri> resultList = new ArrayList<>();
        String[] results = intent.getStringArrayExtra(ImagePickFunction.Extras.Result);
        for (String result : results) {
            resultList.add(Uri.fromFile(new File(result)));
        }
        onPickSuccess(requestCode, intent, resultList);
    }

}
